﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 学生管理
{
    public partial class FormInformation : Form
    {
        public FormInformation()
        {
            InitializeComponent();
            ShowList();
        }

        private void ShowList()
        {
            List<Student1> stulist = new List<Student1>();//建立学生类列表
            BindingList<Student1> Blist;
            //将BindingList赋值给DataGridView.DataSource, 如此直接操作BindingList对象时，DataGridView的结果会动态随之更新
            Blist = new BindingList<Student1>(stulist);

            Blist.Add(new Student1()
            {
                ID = "201901",
                Name = "小王",
                Major = "计算机科学",
                Age = "20",
            }) ;
            Blist.Add(new Student1()
            {
                ID = "201902",
                Name = "小华",
                Major = "网络工程",
                Age = "21",
            });
            Blist.Add(new Student1()
            {
                ID = "201903",
                Name = "小丽",
                Major = "大数据",
                Age = "19",
            });
            
            //稍后添加文件存储以及list的增添删改
            this.Datagv_Inf.DataSource = Blist;
        }

        private void Btn_down_Click(object sender, EventArgs e)
        {
            Form form = new FormShow();
            form.Show();
        }

        private void FormInformation_Load(object sender, EventArgs e)
        {

        }
    }

    public partial class Student1//定义学生类，稍后用list容器类来实现存储，删改等操作
    {
        public string ID { get; set; }
        public string Name { get; set; }
        public string Major { get; set; }
        public string Age { get; set; }
    }


}
